<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="订单号" prop="ddh">
        <el-input
          v-model="queryParams.ddh"
          placeholder="请输入订单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料编码" prop="wlbm">
        <el-input
          v-model="queryParams.wlbm"
          placeholder="请输入物料编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料名称" prop="wlmc">
        <el-input
          v-model="queryParams.wlmc"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="单位" prop="dw">
        <el-input
          v-model="queryParams.dw"
          placeholder="请输入单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="数量" prop="sl">
        <el-input
          v-model="queryParams.sl"
          placeholder="请输入数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="下单日期">
        <el-date-picker
          v-model="daterangeXdrq"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="交货日期">
        <el-date-picker
          v-model="daterangeJhrq"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="规格要求" title="规格要求" prop="ggyq">
        <el-input
          v-model="queryParams.ggyq"
          placeholder="请输入规格要求(板厚,单件用量)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工艺路线" prop="gylx">
        <el-input
          v-model="queryParams.gylx"
          placeholder="请输入工艺路线"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="机加工工序" prop="jjggx">
        <el-input
          v-model="queryParams.jjggx"
          placeholder="请输入机加工工序"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="重量" prop="zl">
        <el-input
          v-model="queryParams.zl"
          placeholder="请输入重量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户名称" prop="khmc">
        <el-input
          v-model="queryParams.khmc"
          placeholder="请输入客户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订货商机构代码,导入此订单的用户所属机构代码" prop="dhsDeptId">
        <el-input
          v-model="queryParams.dhsDeptId"
          placeholder="请输入订货商机构代码,导入此订单的用户所属机构代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商部门名称" prop="deptName">
        <el-input
          v-model="queryParams.deptName"
          placeholder="请输入供应商部门名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商部门ID" prop="deptId">
        <el-input
          v-model="queryParams.deptId"
          placeholder="请输入供应商部门ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单备注" prop="ddbz">
        <el-input
          v-model="queryParams.ddbz"
          placeholder="请输入订单备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单类型,1自制,2外协,3外协转自制" prop="ddlx">
        <el-select v-model="queryParams.ddlx" placeholder="请选择订单类型,1自制,2外协,3外协转自制" clearable>
          <el-option
            v-for="dict in dict.type.sys_ddlx"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="外协订单ID,对于外协转自制的记录" prop="wxddid">
        <el-input
          v-model="queryParams.wxddid"
          placeholder="请输入外协订单ID,对于外协转自制的记录"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商单价,由供应商维护" prop="ghsdj">
        <el-input
          v-model="queryParams.ghsdj"
          placeholder="请输入供应商单价,由供应商维护"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商总价,系统自动计算" prop="ghszj">
        <el-input
          v-model="queryParams.ghszj"
          placeholder="请输入供应商总价,系统自动计算"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供货商价格备注" prop="ghsjgbz">
        <el-input
          v-model="queryParams.ghsjgbz"
          placeholder="请输入供货商价格备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商价格维护人" prop="ghsjgwhr">
        <el-input
          v-model="queryParams.ghsjgwhr"
          placeholder="请输入供应商价格维护人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供货商价格维护时间" prop="ghsjgwhsj">
        <el-input
          v-model="queryParams.ghsjgwhsj"
          placeholder="请输入供货商价格维护时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总部价格审核状态1,1审核通过,0驳回" prop="zbjgshzt1">
        <el-select v-model="queryParams.zbjgshzt1" placeholder="请选择总部价格审核状态1,1审核通过,0驳回" clearable>
          <el-option
            v-for="dict in dict.type.sys_shzt"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="总部价格审核1审核意见" prop="zbjgsh1shyj">
        <el-input
          v-model="queryParams.zbjgsh1shyj"
          placeholder="请输入总部价格审核1审核意见"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总部价格审核1审核时间" prop="zbjgsh1shsj">
        <el-input
          v-model="queryParams.zbjgsh1shsj"
          placeholder="请输入总部价格审核1审核时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总部价格审核状态2,1审核通过,0驳回" prop="zbjgshzt2">
        <el-select v-model="queryParams.zbjgshzt2" placeholder="请选择总部价格审核状态2,1审核通过,0驳回" clearable>
          <el-option
            v-for="dict in dict.type.sys_shzt"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="总部价格审核2审核意见" prop="zbjgsh2shyj">
        <el-input
          v-model="queryParams.zbjgsh2shyj"
          placeholder="请输入总部价格审核2审核意见"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总部价格审核2审核时间" prop="zbjgsh2shsj">
        <el-input
          v-model="queryParams.zbjgsh2shsj"
          placeholder="请输入总部价格审核2审核时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料类型,1正常,2补料" prop="wllx">
        <el-select v-model="queryParams.wllx" placeholder="请选择物料类型,1正常,2补料" clearable>
          <el-option
            v-for="dict in dict.type.sys_wllx"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="物料审核状态1,辅料需审核,1审核通过,0驳回" prop="wlshzt1">
        <el-select v-model="queryParams.wlshzt1" placeholder="请选择物料审核状态1,辅料需审核,1审核通过,0驳回" clearable>
          <el-option
            v-for="dict in dict.type.sys_shzt"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="物料审核1更新时间" prop="wlsh1gxsj">
        <el-input
          v-model="queryParams.wlsh1gxsj"
          placeholder="请输入物料审核1更新时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料审核状态2,辅料需审核,1审核通过,0驳回" prop="wlshzt2">
        <el-select v-model="queryParams.wlshzt2" placeholder="请选择物料审核状态2,辅料需审核,1审核通过,0驳回" clearable>
          <el-option
            v-for="dict in dict.type.sys_shzt"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="物料审核2审核意见" prop="wlsh2shyj">
        <el-input
          v-model="queryParams.wlsh2shyj"
          placeholder="请输入物料审核2审核意见"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料审核2审核时间" prop="wlsh2gxsj">
        <el-input
          v-model="queryParams.wlsh2gxsj"
          placeholder="请输入物料审核2审核时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入库状态,10待入库,11已入库" prop="rkzt">
        <el-select v-model="queryParams.rkzt" placeholder="请选择入库状态,10待入库,11已入库" clearable>
          <el-option
            v-for="dict in dict.type.sys_rkzt"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="入库备注" prop="rkbz">
        <el-input
          v-model="queryParams.rkbz"
          placeholder="请输入入库备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入库时间" prop="rksj">
        <el-input
          v-model="queryParams.rksj"
          placeholder="请输入入库时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入库人" prop="rkr">
        <el-input
          v-model="queryParams.rkr"
          placeholder="请输入入库人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出库状态,20待出库,21已出库" prop="ckzt">
        <el-select v-model="queryParams.ckzt" placeholder="请选择出库状态,20待出库,21已出库" clearable>
          <el-option
            v-for="dict in dict.type.sys_ckzt"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="出库备注" prop="ckbz">
        <el-input
          v-model="queryParams.ckbz"
          placeholder="请输入出库备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出库时间" prop="cksj">
        <el-input
          v-model="queryParams.cksj"
          placeholder="请输入出库时间,纯外协入库即出库；纯自制无入库有出库；外协转自制有入库，二次加工完成后，有出库"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出库人" prop="ckr">
        <el-input
          v-model="queryParams.ckr"
          placeholder="请输入出库人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单状态(总体状态),10待入库,11已入库,20待出库,21已出库" prop="ddzt">
        <el-select v-model="queryParams.ddzt" placeholder="请选择订单状态(总体状态),10待入库,11已入库,20待出库,21已出库" clearable>
          <el-option
            v-for="dict in dict.type.sys_ddzt"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="录入人" prop="createby">
        <el-input
          v-model="queryParams.createby"
          placeholder="请输入录入人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="录入时间" prop="createtime">
        <el-input
          v-model="queryParams.createtime"
          placeholder="请输入录入时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="更新人" prop="updateby">
        <el-input
          v-model="queryParams.updateby"
          placeholder="请输入更新人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="更新时间" prop="updatetime">
        <el-input
          v-model="queryParams.updatetime"
          placeholder="请输入更新时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否删除,0否1是" prop="sfsc">
        <el-select v-model="queryParams.sfsc" placeholder="请选择是否删除,0否1是" clearable>
          <el-option
            v-for="dict in dict.type.sys_yw_shifou"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否已开发票,0否1是" prop="sfykp">
        <el-select v-model="queryParams.sfykp" placeholder="请选择是否已开发票,0否1是" clearable>
          <el-option
            v-for="dict in dict.type.sys_yw_shifou"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="发票ID" prop="fpid">
        <el-input
          v-model="queryParams.fpid"
          placeholder="请输入发票ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:ddgl:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:ddgl:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:ddgl:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:ddgl:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="ddglList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="订单ID" align="center" prop="ddid" />
      <el-table-column label="订单号" align="center" prop="ddh" />
      <el-table-column label="物料编码" align="center" prop="wlbm" />
      <el-table-column label="物料名称" align="center" prop="wlmc" />
      <el-table-column label="单位" align="center" prop="dw" />
      <el-table-column label="数量" align="center" prop="sl" />
      <el-table-column label="下单日期" align="center" prop="xdrq" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.xdrq, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="交货日期" align="center" prop="jhrq" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jhrq, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="规格要求" title="规格要求(下级零件,板厚,单件用量)" align="center" prop="ggyq" />
      <el-table-column label="工艺路线" align="center" prop="gylx" />
      <el-table-column label="机加工工序" align="center" prop="jjggx" />
      <el-table-column label="重量" align="center" prop="zl" />
      <el-table-column label="客户名称" align="center" prop="khmc" />
      <el-table-column label="订货商机构代码,导入此订单的用户所属机构代码" align="center" prop="dhsDeptId" />
      <el-table-column label="供应商部门名称" align="center" prop="deptName" />
      <el-table-column label="供应商部门ID" align="center" prop="deptId" />
      <el-table-column label="订单备注" align="center" prop="ddbz" />
      <el-table-column label="订单类型,1自制,2外协,3外协转自制" align="center" prop="ddlx">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_ddlx" :value="scope.row.ddlx"/>
        </template>
      </el-table-column>
      <el-table-column label="外协订单ID,对于外协转自制的记录" align="center" prop="wxddid" />
      <el-table-column label="供应商单价,由供应商维护" align="center" prop="ghsdj" />
      <el-table-column label="供应商总价,系统自动计算" align="center" prop="ghszj" />
      <el-table-column label="供货商价格备注" align="center" prop="ghsjgbz" />
      <el-table-column label="供应商价格维护人" align="center" prop="ghsjgwhr" />
      <el-table-column label="供货商价格维护时间" align="center" prop="ghsjgwhsj" />
      <el-table-column label="总部价格审核状态1,1审核通过,0驳回" align="center" prop="zbjgshzt1">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_shzt" :value="scope.row.zbjgshzt1"/>
        </template>
      </el-table-column>
      <el-table-column label="总部价格审核1审核意见" align="center" prop="zbjgsh1shyj" />
      <el-table-column label="总部价格审核1审核时间" align="center" prop="zbjgsh1shsj" />
      <el-table-column label="总部价格审核状态2,1审核通过,0驳回" align="center" prop="zbjgshzt2">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_shzt" :value="scope.row.zbjgshzt2"/>
        </template>
      </el-table-column>
      <el-table-column label="总部价格审核2审核意见" align="center" prop="zbjgsh2shyj" />
      <el-table-column label="总部价格审核2审核时间" align="center" prop="zbjgsh2shsj" />
      <el-table-column label="物料类型,1正常,2补料" align="center" prop="wllx">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_wllx" :value="scope.row.wllx"/>
        </template>
      </el-table-column>
      <el-table-column label="物料审核状态1,辅料需审核,1审核通过,0驳回" align="center" prop="wlshzt1">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_shzt" :value="scope.row.wlshzt1"/>
        </template>
      </el-table-column>
      <el-table-column label="物料审核1审核意见" align="center" prop="wlsh1shyj" />
      <el-table-column label="物料审核1更新时间" align="center" prop="wlsh1gxsj" />
      <el-table-column label="物料审核状态2,辅料需审核,1审核通过,0驳回" align="center" prop="wlshzt2">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_shzt" :value="scope.row.wlshzt2"/>
        </template>
      </el-table-column>
      <el-table-column label="物料审核2审核意见" align="center" prop="wlsh2shyj" />
      <el-table-column label="物料审核2审核时间" align="center" prop="wlsh2gxsj" />
      <el-table-column label="入库状态,10待入库,11已入库" align="center" prop="rkzt">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_rkzt" :value="scope.row.rkzt"/>
        </template>
      </el-table-column>
      <el-table-column label="入库备注" align="center" prop="rkbz" />
      <el-table-column label="入库时间" align="center" prop="rksj" />
      <el-table-column label="入库人" align="center" prop="rkr" />
      <el-table-column label="出库状态,20待出库,21已出库" align="center" prop="ckzt">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_ckzt" :value="scope.row.ckzt"/>
        </template>
      </el-table-column>
      <el-table-column label="出库备注" align="center" prop="ckbz" />
      <el-table-column label="出库时间,纯外协入库即出库；纯自制无入库有出库；外协转自制有入库，二次加工完成后，有出库" align="center" prop="cksj" />
      <el-table-column label="出库人" align="center" prop="ckr" />
      <el-table-column label="订单状态(总体状态),10待入库,11已入库,20待出库,21已出库" align="center" prop="ddzt">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_ddzt" :value="scope.row.ddzt"/>
        </template>
      </el-table-column>
      <el-table-column label="录入人" align="center" prop="createby" />
      <el-table-column label="录入时间" align="center" prop="createtime" />
      <el-table-column label="更新人" align="center" prop="updateby" />
      <el-table-column label="更新时间" align="center" prop="updatetime" />
      <el-table-column label="是否删除,0否1是" align="center" prop="sfsc">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yw_shifou" :value="scope.row.sfsc"/>
        </template>
      </el-table-column>
      <el-table-column label="是否已开发票,0否1是" align="center" prop="sfykp">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yw_shifou" :value="scope.row.sfykp"/>
        </template>
      </el-table-column>
      <el-table-column label="发票ID" align="center" prop="fpid" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:ddgl:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:ddgl:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改进销存_计划与订单管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="订单号" prop="ddh">
          <el-input v-model="form.ddh" placeholder="请输入订单号" />
        </el-form-item>
        <el-form-item label="物料编码" prop="wlbm">
          <el-input v-model="form.wlbm" placeholder="请输入物料编码" />
        </el-form-item>
        <el-form-item label="物料名称" prop="wlmc">
          <el-input v-model="form.wlmc" placeholder="请输入物料名称" />
        </el-form-item>
        <el-form-item label="单位" prop="dw">
          <el-input v-model="form.dw" placeholder="请输入单位" />
        </el-form-item>
        <el-form-item label="数量" prop="sl">
          <el-input v-model="form.sl" placeholder="请输入数量" />
        </el-form-item>
        <el-form-item label="下单日期" prop="xdrq">
          <el-date-picker clearable
            v-model="form.xdrq"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择下单日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="交货日期" prop="jhrq">
          <el-date-picker clearable
            v-model="form.jhrq"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择交货日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="规格要求(下级零件,板厚,单件用量)" prop="ggyq">
          <el-input v-model="form.ggyq" placeholder="请输入规格要求(下级零件,板厚,单件用量)" />
        </el-form-item>
        <el-form-item label="工艺路线" prop="gylx">
          <el-input v-model="form.gylx" placeholder="请输入工艺路线" />
        </el-form-item>
        <el-form-item label="机加工工序" prop="jjggx">
          <el-input v-model="form.jjggx" placeholder="请输入机加工工序" />
        </el-form-item>
        <el-form-item label="重量" prop="zl">
          <el-input v-model="form.zl" placeholder="请输入重量" />
        </el-form-item>
        <el-form-item label="客户名称" prop="khmc">
          <el-input v-model="form.khmc" placeholder="请输入客户名称" />
        </el-form-item>
        <el-form-item label="订货商机构代码,导入此订单的用户所属机构代码" prop="dhsDeptId">
          <el-input v-model="form.dhsDeptId" placeholder="请输入订货商机构代码,导入此订单的用户所属机构代码" />
        </el-form-item>
        <el-form-item label="供应商部门名称" prop="deptName">
          <el-input v-model="form.deptName" placeholder="请输入供应商部门名称" />
        </el-form-item>
        <el-form-item label="供应商部门ID" prop="deptId">
          <el-input v-model="form.deptId" placeholder="请输入供应商部门ID" />
        </el-form-item>
        <el-form-item label="订单备注" prop="ddbz">
          <el-input v-model="form.ddbz" placeholder="请输入订单备注" />
        </el-form-item>
        <el-form-item label="订单类型,1自制,2外协,3外协转自制" prop="ddlx">
          <el-select v-model="form.ddlx" placeholder="请选择订单类型,1自制,2外协,3外协转自制">
            <el-option
              v-for="dict in dict.type.sys_ddlx"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="外协订单ID,对于外协转自制的记录" prop="wxddid">
          <el-input v-model="form.wxddid" placeholder="请输入外协订单ID,对于外协转自制的记录" />
        </el-form-item>
        <el-form-item label="供应商单价,由供应商维护" prop="ghsdj">
          <el-input v-model="form.ghsdj" placeholder="请输入供应商单价,由供应商维护" />
        </el-form-item>
        <el-form-item label="供应商总价,系统自动计算" prop="ghszj">
          <el-input v-model="form.ghszj" placeholder="请输入供应商总价,系统自动计算" />
        </el-form-item>
        <el-form-item label="供货商价格备注" prop="ghsjgbz">
          <el-input v-model="form.ghsjgbz" placeholder="请输入供货商价格备注" />
        </el-form-item>
        <el-form-item label="供应商价格维护人" prop="ghsjgwhr">
          <el-input v-model="form.ghsjgwhr" placeholder="请输入供应商价格维护人" />
        </el-form-item>
        <el-form-item label="供货商价格维护时间" prop="ghsjgwhsj">
          <el-input v-model="form.ghsjgwhsj" placeholder="请输入供货商价格维护时间" />
        </el-form-item>
        <el-form-item label="总部价格审核状态1,1审核通过,0驳回" prop="zbjgshzt1">
          <el-radio-group v-model="form.zbjgshzt1">
            <el-radio
              v-for="dict in dict.type.sys_shzt"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="总部价格审核1审核意见" prop="zbjgsh1shyj">
          <el-input v-model="form.zbjgsh1shyj" placeholder="请输入总部价格审核1审核意见" />
        </el-form-item>
        <el-form-item label="总部价格审核1审核时间" prop="zbjgsh1shsj">
          <el-input v-model="form.zbjgsh1shsj" placeholder="请输入总部价格审核1审核时间" />
        </el-form-item>
        <el-form-item label="总部价格审核状态2,1审核通过,0驳回" prop="zbjgshzt2">
          <el-radio-group v-model="form.zbjgshzt2">
            <el-radio
              v-for="dict in dict.type.sys_shzt"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="总部价格审核2审核意见" prop="zbjgsh2shyj">
          <el-input v-model="form.zbjgsh2shyj" placeholder="请输入总部价格审核2审核意见" />
        </el-form-item>
        <el-form-item label="总部价格审核2审核时间" prop="zbjgsh2shsj">
          <el-input v-model="form.zbjgsh2shsj" placeholder="请输入总部价格审核2审核时间" />
        </el-form-item>
        <el-form-item label="物料类型,1正常,2补料" prop="wllx">
          <el-select v-model="form.wllx" placeholder="请选择物料类型,1正常,2补料">
            <el-option
              v-for="dict in dict.type.sys_wllx"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="物料审核状态1,辅料需审核,1审核通过,0驳回" prop="wlshzt1">
          <el-radio-group v-model="form.wlshzt1">
            <el-radio
              v-for="dict in dict.type.sys_shzt"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="物料审核1更新时间" prop="wlsh1gxsj">
          <el-input v-model="form.wlsh1gxsj" placeholder="请输入物料审核1更新时间" />
        </el-form-item>
        <el-form-item label="物料审核状态2,辅料需审核,1审核通过,0驳回" prop="wlshzt2">
          <el-radio-group v-model="form.wlshzt2">
            <el-radio
              v-for="dict in dict.type.sys_shzt"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="物料审核2审核意见" prop="wlsh2shyj">
          <el-input v-model="form.wlsh2shyj" placeholder="请输入物料审核2审核意见" />
        </el-form-item>
        <el-form-item label="物料审核2审核时间" prop="wlsh2gxsj">
          <el-input v-model="form.wlsh2gxsj" placeholder="请输入物料审核2审核时间" />
        </el-form-item>
        <el-form-item label="入库状态,10待入库,11已入库" prop="rkzt">
          <el-radio-group v-model="form.rkzt">
            <el-radio
              v-for="dict in dict.type.sys_rkzt"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="入库备注" prop="rkbz">
          <el-input v-model="form.rkbz" placeholder="请输入入库备注" />
        </el-form-item>
        <el-form-item label="入库时间" prop="rksj">
          <el-input v-model="form.rksj" placeholder="请输入入库时间" />
        </el-form-item>
        <el-form-item label="入库人" prop="rkr">
          <el-input v-model="form.rkr" placeholder="请输入入库人" />
        </el-form-item>
        <el-form-item label="出库状态,20待出库,21已出库" prop="ckzt">
          <el-radio-group v-model="form.ckzt">
            <el-radio
              v-for="dict in dict.type.sys_ckzt"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="出库备注" prop="ckbz">
          <el-input v-model="form.ckbz" placeholder="请输入出库备注" />
        </el-form-item>
        <el-form-item label="出库时间,纯外协入库即出库；纯自制无入库有出库；外协转自制有入库，二次加工完成后，有出库" prop="cksj">
          <el-input v-model="form.cksj" placeholder="请输入出库时间,纯外协入库即出库；纯自制无入库有出库；外协转自制有入库，二次加工完成后，有出库" />
        </el-form-item>
        <el-form-item label="出库人" prop="ckr">
          <el-input v-model="form.ckr" placeholder="请输入出库人" />
        </el-form-item>
        <el-form-item label="订单状态(总体状态),10待入库,11已入库,20待出库,21已出库" prop="ddzt">
          <el-select v-model="form.ddzt" placeholder="请选择订单状态(总体状态),10待入库,11已入库,20待出库,21已出库">
            <el-option
              v-for="dict in dict.type.sys_ddzt"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否删除,0否1是" prop="sfsc">
          <el-radio-group v-model="form.sfsc">
            <el-radio
              v-for="dict in dict.type.sys_yw_shifou"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否已开发票,0否1是" prop="sfykp">
          <el-radio-group v-model="form.sfykp">
            <el-radio
              v-for="dict in dict.type.sys_yw_shifou"
              :key="dict.value"
              :label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="发票ID" prop="fpid">
          <el-input v-model="form.fpid" placeholder="请输入发票ID" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listDdgl, getDdgl, delDdgl, addDdgl, updateDdgl } from "@/api/system/ddgl";

export default {
  name: "Ddgl",
  dicts: ['sys_ddzt', 'sys_shzt', 'sys_rkzt', 'sys_ckzt', 'sys_ddlx', 'sys_wllx', 'sys_yw_shifou'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 进销存_计划与订单管理表格数据
      ddglList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 发票ID时间范围
      daterangeXdrq: [],
      // 发票ID时间范围
      daterangeJhrq: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ddh: null,
        wlbm: null,
        wlmc: null,
        dw: null,
        sl: null,
        xdrq: null,
        jhrq: null,
        ggyq: null,
        gylx: null,
        jjggx: null,
        zl: null,
        khmc: null,
        dhsDeptId: null,
        deptName: null,
        deptId: null,
        ddbz: null,
        ddlx: null,
        wxddid: null,
        ghsdj: null,
        ghszj: null,
        ghsjgbz: null,
        ghsjgwhr: null,
        ghsjgwhsj: null,
        zbjgshzt1: null,
        zbjgsh1shyj: null,
        zbjgsh1shsj: null,
        zbjgshzt2: null,
        zbjgsh2shyj: null,
        zbjgsh2shsj: null,
        wllx: null,
        wlshzt1: null,
        wlsh1shyj: null,
        wlsh1gxsj: null,
        wlshzt2: null,
        wlsh2shyj: null,
        wlsh2gxsj: null,
        rkzt: null,
        rkbz: null,
        rksj: null,
        rkr: null,
        ckzt: null,
        ckbz: null,
        cksj: null,
        ckr: null,
        ddzt: null,
        createby: null,
        createtime: null,
        updateby: null,
        updatetime: null,
        sfsc: null,
        sfykp: null,
        fpid: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        ddh: [
          { required: true, message: "订单号不能为空", trigger: "blur" }
        ],
        createby: [
          { required: true, message: "录入人不能为空", trigger: "blur" }
        ],
        createtime: [
          { required: true, message: "录入时间不能为空", trigger: "blur" }
        ],
        updateby: [
          { required: true, message: "更新人不能为空", trigger: "blur" }
        ],
        updatetime: [
          { required: true, message: "更新时间不能为空", trigger: "blur" }
        ],
        sfsc: [
          { required: true, message: "是否删除,0否1是不能为空", trigger: "change" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询进销存_计划与订单管理列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeXdrq && '' != this.daterangeXdrq) {
        this.queryParams.params["beginXdrq"] = this.daterangeXdrq[0];
        this.queryParams.params["endXdrq"] = this.daterangeXdrq[1];
      }
      if (null != this.daterangeJhrq && '' != this.daterangeJhrq) {
        this.queryParams.params["beginJhrq"] = this.daterangeJhrq[0];
        this.queryParams.params["endJhrq"] = this.daterangeJhrq[1];
      }
      listDdgl(this.queryParams).then(response => {
        this.ddglList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        ddid: null,
        ddh: null,
        wlbm: null,
        wlmc: null,
        dw: null,
        sl: null,
        xdrq: null,
        jhrq: null,
        ggyq: null,
        gylx: null,
        jjggx: null,
        zl: null,
        khmc: null,
        dhsDeptId: null,
        deptName: null,
        deptId: null,
        ddbz: null,
        ddlx: null,
        wxddid: null,
        ghsdj: null,
        ghszj: null,
        ghsjgbz: null,
        ghsjgwhr: null,
        ghsjgwhsj: null,
        zbjgshzt1: null,
        zbjgsh1shyj: null,
        zbjgsh1shsj: null,
        zbjgshzt2: null,
        zbjgsh2shyj: null,
        zbjgsh2shsj: null,
        wllx: null,
        wlshzt1: null,
        wlsh1shyj: null,
        wlsh1gxsj: null,
        wlshzt2: null,
        wlsh2shyj: null,
        wlsh2gxsj: null,
        rkzt: null,
        rkbz: null,
        rksj: null,
        rkr: null,
        ckzt: null,
        ckbz: null,
        cksj: null,
        ckr: null,
        ddzt: null,
        createby: null,
        createtime: null,
        updateby: null,
        updatetime: null,
        sfsc: null,
        sfykp: null,
        fpid: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeXdrq = [];
      this.daterangeJhrq = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.ddid)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加进销存_计划与订单管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const ddid = row.ddid || this.ids
      getDdgl(ddid).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改进销存_计划与订单管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.ddid != null) {
            updateDdgl(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addDdgl(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ddids = row.ddid || this.ids;
      this.$modal.confirm('是否确认删除进销存_计划与订单管理编号为"' + ddids + '"的数据项？').then(function() {
        return delDdgl(ddids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/ddgl/export', {
        ...this.queryParams
      }, `ddgl_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
